package com.example.mooctao;

import android.os.Bundle;
import android.os.PersistableBundle;
import android.view.View;

import androidx.activity.EdgeToEdge;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.fragment.app.FragmentTransaction;

import com.example.mooctao.fragment.FindFragment;
import com.example.mooctao.fragment.IndexFragment;
import com.example.mooctao.fragment.MeFragment;
//主界面，切换我的，首页，发现页面
public class MainActivity extends AppCompatActivity {
    private IndexFragment index;
    private FindFragment find;
    private MeFragment me;


    //创建视图
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        index = new IndexFragment();
        find = new FindFragment();
        me = new MeFragment();

        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        transaction.add(R.id.container,index);
        transaction.commit();
    }
     //点击按钮，切换页面
    public void myclick(View v) {
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        switch (v.getId()) {
            case R.id.index:
                transaction.replace(R.id.container,index);
                break;
            case R.id.find:

                transaction.replace(R.id.container,find);
                break;
            case R.id.me:
                transaction.replace(R.id.container,me);
                break;
        }
        transaction.commit();
    }

}
